<template>
	<view>
		<image class="bg" mode="widthFix" src="@/static/imgs/head5.png"></image>
		<view class="cantainer">
			<view class="status_bar"><!-- 这里是状态栏 --></view>
			<view class="my">我的</view>
			<view class="flexBox">
				<view class="userImg">
					<uni-icons type="person-filled" color="#000" size="44"></uni-icons>
				</view>
				<view class="name">
					{{ info.user.username }}
				</view>
			</view>
			<view class="whiteBox">
				<view class="lis" @click="update">
					<uni-icons type="calendar" color="#000" size="20"></uni-icons>
					<span>版本更新</span>
					<span class="flow"></span>
					<uni-icons type="right" color="#000" size="20"></uni-icons>
				</view>
				<view class="lis" @click="logout">
					<uni-icons type="redo" color="#000" size="20"></uni-icons>
					<span>退出登录</span>
					<span class="flow"></span>
					<uni-icons type="right" color="#000" size="20"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			info: {},
		};
	},
	onShow() {
		this.init();
	},
	methods: {
		init() {
			let user = JSON.parse(uni.getStorageSync('userInfo') || 'false') || {user: '未知'};
			this.info = user
		},
		logout() {
			uni.showModal({
				title: '提示',
				content: '确定退出登录？',
				success: (res) => {
					if (res.confirm) {
						uni.removeStorageSync('token');
						uni.reLaunch({
							url: '/pages/login'
						});
					} else if (res.cancel) {
					}
				}
			});
		},
		update() {
			this.$msg('已是最新版本，无需更新')
		}
	}
}
</script>

<style lang="scss">
.flexBox {
	display: flex;
	align-items: center;
	margin: 20px 0;
}

.name {
	font-size: 20px;
}

.lis {
	display: flex;
	align-items: center;
	padding: 10px;

	span {
		font-size: 14px;
		margin: 0 10px;
	}

	.flow {
		flex-grow: 1;
	}
}

.userImg {
	width: 64px;
	height: 64px;
	border: 2px solid #fff;
	border-radius: 50%;
	margin-right: 20px;
	text-align: center;
	background: #e0effd;
}

.my {
	margin-top: 30px;
	font-size: 18px;
	color: #2A5E55;
	font-weight: bold;
}

.bg {
	width: 100%;
	position: absolute;
	top: 0;
	z-index: 0;
}
</style>